#!/bin/bash

source ../common/common.sh
owndir=`pwd`

show t "安装proxychains sshpass"
install_apt_pack "force|proxychains sshpass"
if [ -f /etc/proxychains.conf ]; then
  find_replace_line /etc/proxychains.conf \
  	"socks4 	127.0.0.1 9050" \
	"socks5  127.0.0.1 7070" \
	"1"
fi
if [ -f /usr/lib/proxychains3/proxyresolv ]; then
  find_replace_line /usr/lib/proxychains3/proxyresolv \
  	"DNS_SERVER=\${PROXYRESOLV_DNS:-4.2.2.2}" \
	"DNS_SERVER=\${PROXYRESOLV_DNS:-8.8.4.4}" \
	"1"
fi

OPTBIN=/opt/bin
SSHUSA=$OPTBIN/ssh
if [ ! -f "$SSHUSA" ]; then
  TMPDIR=/tmp/sshusa
  SRCURL=http://www.123ssh.net/obfuscated-openssh.zip
  LF_ZIP=obfuscated-openssh.zip
  LF_DIR=obfuscated-openssh
  TMPZIP=$TMPDIR/$LF_ZIP
  if [ ! -d "$TMPDIR" ]; then
    chk_mkdir $TMPDIR
  fi
  if [ ! -d "$TMPZIP" ]; then
    chk_mkdir $TMPDIR
    chk_downfile $SRCURL $TMPZIP
  fi
  if [ -f $TMPZIP ]; then
    cd $TMPDIR
    if [ ! -d $TMPDIR/$LF_DIR ]; then
      unzip $LF_ZIP
      chmod -Rc 755 $LF_DIR
    fi
    if [ -d $TMPDIR/$LF_DIR ]; then
      cd $TMPDIR/$LF_DIR
      show t "安装ssh usassh/123ssh编译版支持库"
      #install_apt_pack "force|libz libpam-dev libssl-dev libgss-dev libkrb5-dev"
      install_apt_pack "force|libpam0g-dev libssl-dev libgss-dev libkrb5-dev"
      #if [ ! -f $TMPDIR/$LF_DIR/config.h ]; then
      #  ./configure --sysconfdir=/opt/etc --bindir=/opt/bin/ --sbindir=/opt/sbin --sharedstatedir=/opt/lib \
      #    --localstatedir=/opt/lib --libdir=/opt/lib --localedir=/opt/lib --with-pam --with-kerberos5
      #fi
      if [ ! -f $TMPDIR/$LF_DIR/config.h ]; then
        ./configure --sysconfdir=/opt/etc --bindir=/opt/bin --sbindir=/opt/sbin --mandir=/opt/docs --libexecdir=/opt/libexec --with-pam --with-kerberos5
      fi
      if [ ! -f $TMPDIR/$LF_DIR/ssh ]; then make; fi
      if [ -f $TMPDIR/$LF_DIR/ssh ]; then sudo make install; fi
    fi
  fi
fi



